<?php

/**
 * This file is part of the Framework03 PHP framework.
 * @author Walter Tamboer
 * @package Framework03
 */

class TestController extends FW_Controller_Action
{
    public function indexAction()
    {
        return $this->htmlAction();
    }

    public function htmlAction()
    {
        $view = new FW_View_Html($this);

        $view->set('name', 'World');

        return $view;
    }

    public function jsonAction()
    {
        $arr = array ('a'=>1,'b'=>2,'c'=>3,'d'=>4,'e'=>5);

        return new FW_View_Json($arr);
    }
    
    public function debugAction()
    {
        $arr = array ('a'=>1,'b'=>2,'c'=>3,'d'=>4,'e'=>5);

        return new FW_View_Debug($arr);
    }

    public function xmlAction()
    {
        $sXML = '<root><element><key>a</key><value>b</value></element></root>';

        $dom = new DOMDocument();

        $dom->preserveWhiteSpace = false;
        $dom->formatOutput   = true;

        $dom->loadXML($sXML);

        return new FW_View_Xml($dom);
    }

    public function xslAction()
    {
        $sXML = '<root><element><key>a</key><value>b</value></element></root>';

        $dom = new DOMDocument();

        $dom->preserveWhiteSpace = false;
        $dom->formatOutput   = true;

        $dom->loadXML($sXML);

        return new FW_View_Xsl($dom);
    }

    public function plainAction()
    {
        return new FW_View_Plain('Hiep hoi');
    }
}
